import React from 'react'
import { render } from 'react-dom'
import { Router, browserHistory } from 'react-router'
//import routes from './routes/routes'
import './css/common.css'
import './css/index.css'

import Login from './components/Login'

function switchRoute() {
	const pathName = window.location.pathname
	const userInfo = JSON.parse(localStorage.getItem("userInfo"))
	
	if(pathName == "/login") {
		//var Login = require('./components/Login')
		return <Login />
	} else {
		if(!userInfo) {
			location.href = "/login"
		}
		var routes = require('./routes/routes')
		return <Router routes={routes} history={browserHistory}/>
	}
}

render(
  switchRoute(),
  document.getElementById('app')
)
